import Vue from 'vue'
import Cookies from 'js-cookie'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import Element from 'element-ui'

import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log
import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'
import directives from './directive' // global filters
import * as filters from './filters' // global filters
import baseMixin from './mixins/base'
import heyComponent from './components/hey/index'
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import './utils/directives.js'

Vue.use(preview)
Vue.use(ViewUI)
Vue.use(heyComponent)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
// import { mockXHR } from '../mock'
// if (process.env.NODE_ENV === 'production') {
// mockXHR()
// }

Vue.use(Element, {
  size: Cookies.get('size') || 'medium'
})

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

Vue.config.productionTip = false
Vue.mixin(baseMixin)
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
